package com.abe.bathsystem.contract.presenter;

import com.abe.bathsystem.contract.CommonContract;
import com.abe.bathsystem.contract.CommonModel;
import com.abe.bathsystem.entity.ReqBaseEntity;
import com.abe.bathsystem.entity.ReqBaseNoDataEntity;
import com.abe.bathsystem.entity.ReqConstant;
import com.abe.mvpcore.BasePresenter;
import com.abe.mvpcore.OnResultListener;


public class UploadPresenter extends BasePresenter<CommonContract.UploadView, CommonModel> implements CommonContract.UploadPresenter {
    @Override
    public void uploadLog(String fullName) {
        getModel().uploadLog(fullName, new OnResultListener<ReqBaseEntity<Integer>>() {
            @Override
            public void onStart() {

            }

            @Override
            public void onEnd() {
                UploadPresenter.this.onEnd(UploadPresenter.class.getSimpleName() + "-uploadLog");
            }

            @Override
            public void onSuccess(ReqBaseEntity<Integer> data) {
                if (UploadPresenter.this.onSuccess(data)) {
                    getView().onUploadLog(data.getCode() == ReqConstant.NET_RESULT_OK, data.getData(), data.getMsg());
                }
            }

            @Override
            public void onFailure(String message) {
                UploadPresenter.this.onFailure(UploadPresenter.class.getSimpleName() + "-uploadLog");
            }
        });
    }

    @Override
    public void saveLogData(String resId) {
        getModel().saveLogData(resId, new OnResultListener<ReqBaseNoDataEntity>() {
            @Override
            public void onStart() {

            }

            @Override
            public void onEnd() {
                UploadPresenter.this.onEnd(UploadPresenter.class.getSimpleName() + "-saveLogData");

            }

            @Override
            public void onSuccess(ReqBaseNoDataEntity data) {
                if (UploadPresenter.this.onSuccess(data)) {
                    getView().onSaveLog(data.getCode() == ReqConstant.NET_RESULT_OK, data.getMsg());
                }
            }

            @Override
            public void onFailure(String message) {
                UploadPresenter.this.onFailure(UploadPresenter.class.getSimpleName() + "-saveLogData");

            }
        });
    }
}
